Creating Objects

Accessing the objects that the SDK provides is typically started by creating an "instance" of the TurboCAD Application object. Each client application program gets its own copy of the TurboCAD Application object, which represents an editing or viewing session. These sessions are independent of each other.

Creating or Connecting to the Application Object

You can create Automation client applications using Microsoft Visual Basic, Microsoft Visual C++, Enable Basic, or any other application or programming language that supports ActiveX technologies. Your client needs to perform the following steps to access TurboCAD's exposed objects:

Choosing In Process or Local Server

The TurboCAD v4 OLE Automation server can be loaded as an in process (DLL) server, in a custom client application's process with a user interface provided by the client application that you provide. In this way you can read files, create drawings, add, modify and delete graphics, and display drawings on your application's user-defined viewports.

The TurboCAD v4 OLE Automation server can also be run as a local (EXE) server. In this scenario the objects are provided by the TurboCAD v4 application (TCW40.exe), and your client can control and customize the operation of TurboCAD, adding user interface elements, receiving events fired by TurboCAD, and extending the operation of TurboCAD. If TurboCAD has been launched by a user, your client application can also connect to the active running instance of TurboCAD.

In general, in-process servers run faster than local servers. The in-process server is contained in IMSIGX40.DLL, together with support from DBAPI40.DLL, TCAPI40.DLL, and a variety of graphic regeneration method and drawing file format filter DLLs. Use the local server option when you require TurboCAD's user interface (menus, toolbars and windows).

Creating a New Application Object Instance

Each language has a function that is used to create objects in the OLE Automation system. In Visual Basic, the CreateObject function starts up a connection to the server. The CreateObject function takes one argument, a string called the ProgID, with which the OLE Automation system gets information from the Windows registry to locate the TurboCAD server. The in process and local servers have distinct ProgIDs, so make sure you use the correct string. After locating the server the system starts up the server and requests an object.

From Visual Basic:

In Delphi, the same result is accomplished by using the CreateOleObject function in the OleAuto unit.:

In Visual J++, the same result is accomplished by instantiating a new imsigx40.XApplication or imsigx40.Application object and assigning the result to a reference of the imsigx40.IApplication interface.

Finally in C++, or other languages that allow direct calls to the Win32 API, the choice between in process and local servers is also determined by the dwClsContext argument to the CoCreateInstance function:

Connecting to a Running Application Object

Each language also has the ability to connect to an already running copy of TurboCAD.

Previous Next

SDK Top API Reference TurboCAD Home Page TurboCAD Programming Forums